# !/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import string

UNICODE_ASCII_CHARACTERS = (string.ascii_letters + string.digits)


def gen_cache_key(*args):
    """
    组装普通的缓存键
    :param args:
    :return:
    """
    return ":".join(str(_) for _ in args)


def gen_hash_cache_key(*args):
    """
    组装hash的缓存键
    :param args:
    :return:
    """
    return "_".join(str(_) for _ in args)


def random_ascii_string(length):
    """
    生成指定长度的随机字符串(大小写字母+数字)
    :param length:
    :return:
    """
    return ''.join(random.choice(UNICODE_ASCII_CHARACTERS) for _ in range(0, length))


def random_ascii_digits(length):
    """
    生成指定长度的随机数字(仅数字)
    :param length:
    :return:
    """
    return "".join(random.choice(string.digits) for _ in range(0, length))
